#include "BestFit.h"
#include "main.h"

Area *BestFit::alloc(int wanted)
{
    require(wanted > 0);
    require(wanted <= size);

    Area *area = 0;

    area = searcher(wanted);
    if (area)
    {
        return area;
    }
    else
    {
        reclaim();
        if(area = searcher(wanted))
        {
            return area;
        }
        else
        {
            return 0;
        }
    }

}

void BestFit::free(Area *ap)
{

}

Area  *BestFit::searcher(int wanted)
{
    require(wanted > 0);
    require(wanted <= size);
    Area *bestAp;
    //Look through the available areas
    for(ALiterator i = areas.begin(); i != areas.end(); ++i)
    {
        Area *ap = *i;
        if(ap->getSize() >= wanted && ap->getSize() < bestAp->getSize())
        {
            bestAp = ap;
        }
    }

}

bool	BestFit::reclaim()
{
}





